/*
kunpengsecl licensed under the Mulan PSL v2.
You can use this software according to the terms and conditions of
the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at:
    http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.

Author: wangli
Create: 2022-04-01
Description: Using grpc to implement the service API
*/

package clientapi

/*
import (
	"io/ioutil"
	"os"
	"testing"

	"gitee.com/openeuler/kunpengsecl/attestation/tas/config"
)

const serverConfig = `
tasconfig:
  port: 127.0.0.1:40008
  rest: 127.0.0.1:40009
  akskeycertfile: ./ascert.crt
  aksprivkeyfile: ./aspriv.key
  huaweiitcafile: ./Huawei IT Product CA.pem
  DAA_GRP_KEY_SK_X: 65a9bf91ac8832379ff04dd2c6def16d48a56be244f6e19274e97881a776543c65a9bf91ac8832379ff04dd2c6def16d48a56be244f6e19274e97881a776543c
  DAA_GRP_KEY_SK_Y: 126f74258bb0ceca2ae7522c51825f980549ec1ef24f81d189d17e38f1773b56126f74258bb0ceca2ae7522c51825f980549ec1ef24f81d189d17e38f1773b56
  basevalue: "15a38f450be38bcc8d62fa352bc5c33035d72b6964c227a0a6bbabf1d8de2a07 2a5629919ce34441577741b0c202dab37809eb41c1d0341fb27f2c1e567b4a31"
`

const (
	asCertPath = "./ascert.crt"
	asprivPath = "./aspriv.key"
	huaweiPath = "./Huawei IT Product CA.pem"
)

const ascert = `
-----BEGIN CERTIFICATE-----
MIIFazCCA1OgAwIBAgIURBG3rzn2SH3wruHaPKctA2pEqS8wDQYJKoZIhvcNAQEL
BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMjEyMTcxMzE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rWmY07aBea-HbbOFfs0W0DXuJN2um_RTWUOUf7tDbDjNIlaiOidUf8Li0AMlWAu-Sgqr1ackfnq0MwQOoSd6BXqaFnH9RSQGjy3d8E_hD7BFkHr-3diqJ9x-Ie-pvIFcedv4C-jqlJhAuse0jB1nigkIae8u3xL18U"
        },
        "payload":      {
                "version":      "TEE.RA.1.0",
                "timestamp":    "9223372036854770000",
                "scenario":     "sce_as_with_daa",
                "sign_alg":     "PS256",
                "hash_alg":     "HS256",
                "qta_img":      "FaOPRQvji8yNYvo1K8XDMDXXK2lkwiegprur8djeKgc",
                "qta_mem":      "KlYpkZzjREFXd0GwwgLas3gJ60HB0DQfsn8sHlZ7SjE",
                "tcb":  "",
                "ak_pub":       {
                        "kty":  "DAA",
                        "qs":   "QAAAAP9tjoY4PBDyD0jYoox0nJ3Xhura3xVPu7Xy3hGLRC30RzQF1oZsXoKzGec9Hiad46dEZh2JAvewQ5LGHaipiHlAAAAA4YVQ_aQLNwEbzrQc-EqaNAHT8lfLq7vTJfTfHAAyDgzZCRpxbYK0DZ-ZmFHjwNiFtVIZwjtUAacSx_LQwPxEyA"
                }
        },
        "handler":      "provisioning-output"
}
`)

	bufferNoDAA = []byte(
		`
{
        "signature":    {
                "drk_cert":     "TUlJRWtqQ0NBM3FnQXdJQkFnSVJFVk9HdExqeldMKzk2WEpGeWlYSVEwOHdEUVlKS29aSWh2Y05BUUVMQlFBd1BURUxNQWtHQTFVRUJoTUNRMDR4RHpBTkJnTlZCQW9UQmtoMVlYZGxhVEVkTUJzR0ExVUVBeE1VU0hWaGQyVnBJRWxVSUZCeWIyUjFZM1FnUTBFd0hoY05Nakl3TkRFeE1EWXpOVEF5V2hjTk16Y3dOREEzTURZek5UQXlXakE2TVFzd0NRWURWUVFHRXdKRFRqRVBNQTBHQTFVRUNoTUdTSFZoZDJWcE1Sb3dHQVlEVlFRREV4RXdNalpRVUZZeE1FdERNREEwTVRjNVZEQ0NBaUl3RFFZSktvWklodmNOQVFFQkJRQURn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T-8277Hvzq_yxMsVUlsrRU2oXpMWJFXDdlYu8piMftr6VGRg8M0Vy5Tr0O0PP7CpRujklkGgDkqNScpNO7taI8Yn44saEvGhR3P0MluC9MsvVQRQiMk1mmbgyxFpYo-NHBNam5G67Az55CqmdmSGE88qQAhBnRc5bp4pubpVlsA0Or7SG6QMHHq0Tx9pbXjlgcVtNDz7cmXSX7ITZ3p8kcq5vy3RLV3JdXN454e356KmOjhZlCeoRw_fHl1h2lfroUWqQbDpB_FBp5hsNCtqNa94x-J8OM-VvryKrmp-anwqx4RJ3b4FVwtTRU_2EIfgPeidU1Uh2sbdTKkhLw8msf215NfcgcN9J-nPhQtjsUhfjUiYDpbDILqiBabn_VIf0MckyZXdQSD6TKvctOY7SesMUhRx24f3LFOSmIH1yLlu7celsKr5zfDvO4lH4g_HdxlYzJRdM33EE13xkXohGCrpLyjJ4hbP7nrmwKpGJNdM6GcHQj55UowUkCkuFlZfZJz8r3iPUwcg1Gb8SqLqvP1MLAxO7O4JwccdiR8uNo-iEug796_AmOsvqRhiH9oF7V1xa3H84ry0RH-ME"
        },
        "payload":      {
                "version":      "TEE.RA.1.0",
                "timestamp":    "9223372036854770000",
                "scenario":     "sce_as_no_daa",
                "sign_alg":     "PS256",
                "hash_alg":     "HS256",
                "qta_img":      "FaOPRQvji8yNYvo1K8XDMDXXK2lkwiegprur8djeKgc",
                "qta_mem":      "KlYpkZzjREFXd0GwwgLas3gJ60HB0DQfsn8sHlZ7SjE",
                "tcb":  "",
                "ak_pub":       {
                        "kty":  "RSA",
                        "n":    "v88TJ5_JSal574ODMTl2S1T2HMxZtcGcvFJa2CYQ3w7Q8otCZU4tKfXZBXQH4iZGeaBCoNFB1vinzMw5X1hFiPXMHfW-6wc1N-f1DC4Bu-WMhckdcz0qK3_Ptr9EasTs3LB5nUMffBVivm0EzW1LFIOyirY6g3NmKdjJechw9CV7XtosYT50-cgzJCwU1I7l3_qOTHq4nQ4htuuzQUXOh7nTRfFYbYRVLqF9YSFGyb5FL4Zay-2XLWRjqyX93TDN2zNaVcQa2jREAzne5Vx4zomSNe2Fjibke8ykYyvgu3ERsbhK71GAvOLt_Xrx9VpNi_oTjoEofjbh1dD9uFwO8DCk2pJm8SKlVE3b_HV9wLRNQDW13OoCMr5SDxkVIPgMCgXbpdaJRjL41d7dSX3lE45Zy6Tg7TyyAQnhbYwWz87NCnXp0OLjcejEj6xJI391Pids5yTldFfN3b_OgUKEbbNhwbIFtOfW93B15jKTnqaYMCbtsWiQxiJSZuyY6TuIeassbiLUIryzShGw6_kisnecYmzHJdQ7yAU9ZA38QAto1AyvADmfIPeaFVmqp_Z6x8aMLNndowoiwUw2UjgZdGyCDMR_A46OdsuvIec5Uiob5hfa7JIU0jhkez1fAUd8IK4AJ3s6Qd2WqQoO2891eCAvdgXG9XIwJA5cHI0YW30",
                        "e":    "AQAB"
                }
        },
        "handler":      "provisioning-output"
}
`)
)

const (
	configFilePath = "./config.yaml"
)

const (
	// app scenario
	RA_SCENARIO_NO_AS = int32(iota)
	RA_SCENARIO_AS_NO_DAA
	RA_SCENARIO_AS_WITH_DAA
)

func createFiles() {
	err := ioutil.WriteFile(configFilePath, []byte(serverConfig), 0644)
	if err != nil {
		return
	}
	err1 := ioutil.WriteFile(asCertPath, []byte(ascert), 0644)
	if err1 != nil {
		return
	}
	err2 := ioutil.WriteFile(asprivPath, []byte(aspriv), 0644)
	if err2 != nil {
		return
	}
	err3 := ioutil.WriteFile(huaweiPath, []byte(huaweica), 0644)
	if err3 != nil {
		return
	}
}

func removeFiles() {
	err := os.Remove(configFilePath)
	if err != nil {
		return
	}
	err1 := os.Remove(asCertPath)
	if err1 != nil {
		return
	}
	err2 := os.Remove(asprivPath)
	if err2 != nil {
		return
	}
	err3 := os.Remove(huaweiPath)
	if err3 != nil {
		return
	}
}

func TestClientapi(t *testing.T) {
	createFiles()
	defer removeFiles()

	config.LoadConfigs()
	addr := config.GetServerPort()
	go StartServer(addr)
	defer StopServer()

	err := config.InitializeAS()
	if err != nil {
		t.Error(err)
	}

	req_1 := GetAKCertRequest{
		Akcert:   bufferNoDAA,
		Scenario: RA_SCENARIO_AS_NO_DAA,
	}
	_, err = DoGetAKCert(addr, &req_1)
	if err != nil {
		t.Errorf("test DoGetAKCert in scenario RA_SCENARIO_AS_NO_DAA error %v", err)
	}

	req_2 := GetAKCertRequest{
		Akcert:   bufferDAA,
		Scenario: RA_SCENARIO_AS_WITH_DAA,
	}
	_, err = DoGetAKCert(addr, &req_2)
	if err != nil {
		t.Errorf("test DoGetAKCert in scenario RA_SCENARIO_AS_WITH_DAA error %v", err)
	}

	req_3 := GetAKCertRequest{
		Akcert:   nil,
		Scenario: RA_SCENARIO_NO_AS,
	}
	_, err = DoGetAKCert(addr, &req_3)
	if err == nil {
		t.Errorf("test DoGetAKCert in scenario RA_SCENARIO_NO_AS error %v", err)
	}
}
*/
